//
// Created by syshen on 2021/6/28.
//

#ifndef GENERAL_OCR_OCR_H
#define GENERAL_OCR_OCR_H

#include <iostream>
#include <string>
#include <vector>
#include <opencv2/core/core.hpp>

#include "TextDetector/base_detect.h"
#include "TextClassifier/angle.h"
#include "TextRecognizer/base_crnn.h"

typedef struct data_{
    std::vector<std::string> text;
    std::vector<cv::Point2f> points;
}data;

class OCR {
public:
    OCR(int device_id, std::string det_method, std::string recog_method);

    void init(std::string det_model, std::string cls_model, std::string recog_model);

    OCR(const OCR &rhs) = delete;

    OCR operator=(const OCR &rhs) = delete;

    std::vector<data> recognize(const cv::Mat &img);

    ~OCR();

private:
    cv::Mat get_rotate_crop_image(const cv::Mat &img, std::vector <cv::Point2f> &points);

private:
    std::shared_ptr<BaseDetect> detector;
    std::shared_ptr<BaseCrnn>   recognizer;
    std::shared_ptr<AgnleNet>   classifier;

};


#endif //GENERAL_OCR_OCR_H
